import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-04-07
 * Time: 11:04
 */
public class Blur {
    //低通滤波
    //阈值化，二值化
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat src = Imgcodecs.imread("usm.jpg");
//        HighGui.imshow("src1", src);
//        HighGui.waitKey(0);
//
//        Imgproc.cvtColor(src, src, Imgproc.COLOR_BGR2GRAY);
//        Mat mat = new Mat();
//        Imgproc.threshold(src, mat, 125, 225, 0);
//        HighGui.imshow("thresh", mat);
//        HighGui.waitKey(0);
//
        Mat dst = new Mat();
//        Imgproc.blur(src, dst, new Size(5,5));//均值滤波//卷积核越大，图片越模糊
        Imgproc.GaussianBlur(src, dst, new Size(3,3), 10,10);//高斯滤波
//
        HighGui.imshow("src", dst);
        HighGui.waitKey(0);

        Mat mat2 = Imgcodecs.imread("usm.jpg");
        HighGui.imshow("flower", mat2);
        HighGui.waitKey(0);
        Mat dst2 = new Mat();
        Imgproc.medianBlur(mat2, dst2, 3);//中值滤波
        HighGui.imshow("flower1",dst2);
        HighGui.waitKey(0);
        System.out.println("ok");
    }
}
